
package edu.cibertec.servicio;

import java.io.Reader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;


import edu.cibertec.bean.BeanFormula;
import edu.cibertec.bean.BeanIndicador;


public class FormulaService {
	SqlMapClient sqlMap;
	
	public FormulaService() {
		try {
			String resource = "SqlMapConfigApplication.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(
				"Error cargando configuracion en " + this.getClass().getName() + "Cause: " + e);
		}
	}
	
	public ArrayList<BeanFormula> getFormulas(){
		ArrayList<BeanFormula> listaFormula = null;
		try {
			listaFormula = (ArrayList<BeanFormula>)sqlMap.queryForList("getFormulas");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return listaFormula;
	}
}
